import java.util.Objects;

public class LRUListUnit {
    private FrameTableUnit frameTableUnit;
    private int frequency;
    private boolean dirtyBit;

    private LRUListUnit prevUnit;
    private LRUListUnit nextUnit;

    public LRUListUnit(FrameTableUnit frameTableUnit){
        this.frameTableUnit=frameTableUnit;
        this.frequency=0;
        this.dirtyBit=false;
    }

    public void frequencyAdd(){
        this.frequency++;
    }

    public FrameTableUnit getFrameTableUnit() {
        return frameTableUnit;
    }

    public int getFrequency() {
        return frequency;
    }

    public boolean isDirtyBit() {
        return dirtyBit;
    }

    public LRUListUnit getPrevUnit() {
        return prevUnit;
    }

    public LRUListUnit getNextUnit() {
        return nextUnit;
    }

    public void setFrameTableUnit(FrameTableUnit frameTableUnit) {
        this.frameTableUnit = frameTableUnit;
    }

    public void setFrequency(int frequency) {
        this.frequency = frequency;
    }

    public void setDirtyBit(boolean dirtyBit) {
        this.dirtyBit = dirtyBit;
    }

    public void setPrevUnit(LRUListUnit prevUnit) {
        this.prevUnit = prevUnit;
    }

    public void setNextUnit(LRUListUnit nextUnit) {
        this.nextUnit = nextUnit;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        LRUListUnit that = (LRUListUnit) o;
        return Objects.equals(frameTableUnit, that.frameTableUnit);
    }

    @Override
    public int hashCode() {
        return Objects.hash(frameTableUnit, frequency, dirtyBit, prevUnit, nextUnit);
    }
}
